package com.springboot.prac.prac03_algorithm.array;

/**
 * 创建数组的方式
 */
public class CreateArray {
    public static void main(String[] args) {
        array01();
        System.out.print("\n");
        array02();
        System.out.print("\n");
        array03();
    }

    public static void array01() {
        // 数组创建方式1
        int[] arr01 = new int[]{1, 2, 3, 4, 5};

        for (int i : arr01) {
            System.out.print(i);
        }
    }

    public static void array02() {
        // 数组创建方式2
        int[] arr02 = new int[5];
        arr02[0] = 1;
        arr02[4] = 5;

        for (int i : arr02) {
            System.out.print(i);
        }
    }

    public static void array03() {
        // 数组创建方式3
        int[] arr03 = {1, 2, 3, 4, 5};

        for (int i : arr03) {
            System.out.print(i);
        }
    }
}
